package example.string;

/**
 * Created by lenovo on 2016/11/4 0004.
 *  regionMatches() 方法测试两个字符串区域是否相等：
 */
public class RegionMatch {
    public static void main(String[] args){
        String firstStr = "Welcome to Microsoft";
        String secondStr = "I work with microsoft";
        //以下检测字符串中microsoft是否会匹配到
        boolean isMatch1 = firstStr.regionMatches(11,secondStr,12,9);
        boolean isMatch2 = firstStr.regionMatches(true,11,secondStr,12,9);//true 忽略大小写
        System.out.println("区分大小写，字符串区域匹配：" + isMatch1);
        System.out.println("不区分大小写，字符串区域匹配：" + isMatch2);
    }
}
